using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Miris.HumanMilkAnalyser.DataModel;

namespace Miris.HumanMilkAnalyser.Repository.EntityFramework.Mapping
{
    public class PatientMap : EntityTypeConfiguration<Patient>
    {
        public PatientMap()
        {
            // Primary Key
            this.HasKey(t => t.Number);

            // Properties
            this.Property(t => t.Number)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.MotherName)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.MotherDeliveryMode)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.MotherEmotion)
                .HasMaxLength(100);

            this.Property(t => t.MotherBadHabit)
                .HasMaxLength(100);

            this.Property(t => t.BabyName)
                .IsRequired()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Patient");
            this.Property(t => t.Number).HasColumnName("Number");
            this.Property(t => t.MotherName).HasColumnName("MotherName");
            this.Property(t => t.MotherAge).HasColumnName("MotherAge");
            this.Property(t => t.MotherHeight).HasColumnName("MotherHeight");
            this.Property(t => t.MotherWeight).HasColumnName("MotherWeight");
            this.Property(t => t.MotherBMI).HasColumnName("MotherBMI");
            this.Property(t => t.MotherOpenMilkDate).HasColumnName("MotherOpenMilkDate");
            this.Property(t => t.MotherDeliveryMode).HasColumnName("MotherDeliveryMode");
            this.Property(t => t.MotherEmotion).HasColumnName("MotherEmotion");
            this.Property(t => t.MotherBadHabit).HasColumnName("MotherBadHabit");
            this.Property(t => t.BabyName).HasColumnName("BabyName");
            this.Property(t => t.BabyGender).HasColumnName("BabyGender");
            this.Property(t => t.BabyBirthday).HasColumnName("BabyBirthday");
            this.Property(t => t.IsBabyPrematureDelivery).HasColumnName("IsBabyPrematureDelivery");
            this.Property(t => t.BabyHeight).HasColumnName("BabyHeight");
            this.Property(t => t.BabyWeight).HasColumnName("BabyWeight");
            this.Property(t => t.BabyHeadCircumference).HasColumnName("BabyHeadCircumference");
            this.Property(t => t.BabyBirthHeight).HasColumnName("BabyBirthHeight");
            this.Property(t => t.BabyBirthWeight).HasColumnName("BabyBirthWeight");
            this.Property(t => t.BabyBirthHeadCircumference).HasColumnName("BabyBirthHeadCircumference");
            this.Property(t => t.Apgar).HasColumnName("Apgar");
            this.Property(t => t.CreateOn).HasColumnName("CreateOn");
            this.Property(t => t.UpdateOn).HasColumnName("UpdateOn");
        }
    }
}
